package com.example.administrator.printoutindemo;

import android.content.Context;


import com.example.administrator.printoutindemo.database.SQLiteDBService;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class InfoByQRCodeMid implements Serializable {

	private String _projectname;
	private String _material;
	private Integer _gid;
	private String _contractdate;
	private String _supplydate;
	private String _lastinstoredate;
	private String _num;
	private String _unit;
	private String _nums;
	private String _mnums;
	private Integer _mid;
	private String _sname;
	private String _slink;
	private String _sphone;
	private String _remark;
	private String _recoveryOrScrapTime;
	private String _status;
	private String _rsnums;
	private String _arrivalAddress;
	private String _rsprojectname;

	private SQLiteDBService sqliteDBservice;

	public InfoByQRCodeMid() {

	}

	public InfoByQRCodeMid(Context context) {
		sqliteDBservice = new SQLiteDBService(context);
	}

	// 将JSON对象转化为list
	public List<InfoByQRCodeMid> getListFromJSON(String JsonStr) {
		List<InfoByQRCodeMid> clist = new ArrayList<InfoByQRCodeMid>();

		try {

			JSONArray jay = new JSONArray(JsonStr);// 将字符串转化为JSON数组

			for (int i = 0; i < jay.length(); i++) {
				JSONObject temp = (JSONObject) jay.get(i);

				InfoByQRCodeMid n = new InfoByQRCodeMid();

				n.set_projectname(temp.getString("projectname"));
				n.set_material(temp.getString("material"));
				n.set_gid(Integer.parseInt(temp.getString("gid")));
				n.set_contractdate(temp.getString("contractdate"));
				n.set_supplydate(temp.getString("supplyDate"));
				n.set_lastinstoredate(temp.getString("lastInstoreDate"));
				n.set_num(temp.getString("num"));
				n.set_unit(temp.getString("unit"));
				n.set_nums(temp.getString("nums"));
				n.set_mid(Integer.parseInt(temp.getString("mid")));
				n.set_slink(temp.getString("slink"));
				n.set_sphone(temp.getString("sphone"));
				n.set_remark(temp.getString("remark"));
				n.set_arrivalAddress(temp.getString("arrivalAddress"));
				n.set_recoveryOrScrapTime(temp.getString("recoveryOrScrapTime"));
				n.set_rsnums(temp.getString("rsnums"));
				n.set_rsprojectname(temp.getString("rsprojectname"));
				n.set_status(temp.getString("status"));
				n.set_mnums(temp.getString("mnums"));
				n.set_sname(temp.getString("sname"));

				clist.add(n);

			}

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

		return clist;

	}


	// 增加数据SQLite
//		public void add(InfoByQRCodeMid n) {
//			String sql = " insert into areainfo(aid,aname,abh,pid) "
//					+ "values(?,?,?,?) ";
	//
//			sqliteDBservice
//					.execSQL(
//							sql,
//							new Object[] { n.getAid(), n.getAname(), n.getAbh(),
//									n.getPid() });
	//
//		}

	// 获取List列表(从SQLite中获取)
//		public List<AreaInfo> getList(AreaInfo ny, String selection) {
//			List<AreaInfo> li = new ArrayList<AreaInfo>();
	//
//			Cursor cr = sqliteDBservice.query("areainfo", new String[] { "aid",
//					"aname", "abh", "pid" }, selection, null, null, null, null);
	//
//			while (cr.moveToNext()) {
//				AreaInfo n = new AreaInfo();
	//
//				n.setAid(cr.getInt(0));
//				n.setAname(cr.getString(1));
//				n.setAbh(cr.getString(2));
//				n.setPid(cr.getInt(3));
	//
//				li.add(n);
	//
//			}
	//
//			cr.close();
//			sqliteDBservice.closeDBHelper();
//			return li;
//		}

	public String get_mnums() {
		return _mnums;
	}

	public void set_mnums(String _mnums) {
		this._mnums = _mnums;
	}

	public String get_sname() {
		return _sname;
	}

	public void set_sname(String _sname) {
		this._sname = _sname;
	}

	public String get_projectname() {
		return _projectname;
	}

	public String get_recoveryOrScrapTime() {
		return _recoveryOrScrapTime;
	}

	public void set_recoveryOrScrapTime(String _recoveryOrScrapTime) {
		this._recoveryOrScrapTime = _recoveryOrScrapTime;
	}

	public String get_status() {
		return _status;
	}

	public void set_status(String _status) {
		this._status = _status;
	}

	public String get_rsnums() {
		return _rsnums;
	}

	public void set_rsnums(String _rsnums) {
		this._rsnums = _rsnums;
	}

	public String get_arrivalAddress() {
		return _arrivalAddress;
	}

	public void set_arrivalAddress(String _arrivalAddress) {
		this._arrivalAddress = _arrivalAddress;
	}

	public String get_rsprojectname() {
		return _rsprojectname;
	}

	public void set_rsprojectname(String _rsprojectname) {
		this._rsprojectname = _rsprojectname;
	}

	public void set_projectname(String _projectname) {
		this._projectname = _projectname;
	}

	public String get_material() {
		return _material;
	}

	public void set_material(String _material) {
		this._material = _material;
	}

	public Integer get_gid() {
		return _gid;
	}

	public void set_gid(Integer _gid) {
		this._gid = _gid;
	}

	public String get_contractdate() {
		return _contractdate;
	}

	public void set_contractdate(String _contractdate) {
		this._contractdate = _contractdate;
	}

	public String get_supplydate() {
		return _supplydate;
	}

	public void set_supplydate(String _supplydate) {
		this._supplydate = _supplydate;
	}

	public String get_lastinstoredate() {
		return _lastinstoredate;
	}

	public void set_lastinstoredate(String _lastinstoredate) {
		this._lastinstoredate = _lastinstoredate;
	}

	public String get_num() {
		return _num;
	}

	public void set_num(String _num) {
		this._num = _num;
	}

	public String get_unit() {
		return _unit;
	}

	public void set_unit(String _unit) {
		this._unit = _unit;
	}

	public String get_nums() {
		return _nums;
	}

	public void set_nums(String _nums) {
		this._nums = _nums;
	}

	public Integer get_mid() {
		return _mid;
	}

	public void set_mid(Integer _mid) {
		this._mid = _mid;
	}

	public String get_slink() {
		return _slink;
	}

	public void set_slink(String _slink) {
		this._slink = _slink;
	}

	public String get_sphone() {
		return _sphone;
	}

	public void set_sphone(String _sphone) {
		this._sphone = _sphone;
	}
	public String get_remark() {
		return _remark;
	}

	public void set_remark(String _remark) {
		this._remark = _remark;
	}

}